package cn.linjianhui.thread.local;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ParseDate implements Runnable {
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    int i = 0;

    public ParseDate(int i) {
        this.i = i;
    }

    @Override
    public void run() {
        try {
//            synchronized (sdf) {
                Date time = sdf.parse("2020-10-14 13:34:" + String.format("%02d", i % 60));
                System.out.println(time);
//            }
        }catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        ExecutorService es = Executors.newFixedThreadPool(10);
        for(int i = 0; i < 1000; i++) {
            es.execute(new ParseDate(i));
        }

        es.shutdown();
    }
}
